#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;


int main()
{
    int n;
    cin >> n;
    int arr[2][100] = { 0 };
    arr[0][0] = 1;
    int num[2] = { 0 };
    int sum = 0;
    int mid = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
        num[i] *= 10;
        sum += num[i];

    }
    if (n != 1)
    {
        for (int i = 0; i < 2; i++)
        {
            for (int j = 0; j < n - i - 1; j++)
            {
                if (num[i] > num[i + 1])
                {
                    int c = num[i];
                    num[i] = num[i + 1];
                    num[i + 1] = c;

                }
            }
        }
        mid = num[n - 1] - num[n - 2];
    }
    cout << mid << endl;
    int cnt = 0;
    int size[2] = { 0 };
    for (int i = 1; i <=sum -  mid; i++)
    {

        if (size[cnt] < num[cnt])
        {
            arr[cnt][size[cnt]] = i;
            size[cnt]++;
            cnt++;
            cnt %= n;
        }
        else
        {
            cnt++;
            cnt %= n;
            i--;
        }

    }
    if (cnt)
        cnt--;
    else
        cnt = n - 1;
    for (int i = mid; i <= sum; i++)
    {
        if (n != 1)
        {
            arr[cnt][size[cnt]] = arr[cnt][size[cnt] - 1] + 2;
            size[cnt]++;
        }
        else
        {
            arr[cnt][size[cnt]] = arr[cnt][size[cnt] - 1] + 2;
            size[cnt]++;
            arr[0][0] = 1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << '#' << i + 1 << endl;
        for (int j = 0; j < num[i]; j++)
        {

            cout << arr[i][j];
            if ((j + 1) % 10 == 0)
                cout << '\n';
            else
                cout << ' ';
        }

    }
    return 0;
}